#include <57header.h>

void func(int num){
    printf("func run \n");

    sleep(10);

    sigset_t pending;
    sigemptyset(&pending);
    sigpending(&pending);
    
    if(sigismember(&pending, 3)){
        printf("在当前的2号信号处理逻辑中, 有一个3号信号已经到啦, 被屏蔽了 \n");
    }

    printf("func over \n");
}
int main(int argc,char*argv[])
{

    struct sigaction act , old;
    memset(&act, 0, sizeof(act));
    memset(&old, 0, sizeof(old));

    sigset_t set;
    sigemptyset(&set);
    sigaddset(&set, 3);

    act.sa_handler = func;
    act.sa_flags = SA_RESTART;
    act.sa_mask = set;

    sigaction(2, &act, &old);

    char buf[60] = {0};
    read(STDIN_FILENO, buf, sizeof(buf));
    printf("buf: %s \n", buf);

    return 0;
}

